package com.hanamaki.struct;

import java.util.Scanner;

public class BreakDemo02 {

    public static void main(String[] args) {

//        循环录入某学生5门课的成绩并计算平均分，如果某分数录入为负，停止录入并提示录入错误
        double sum = 0;
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        for (int i = 1; i <= 5; i++) {
            System.out.println("请输入第"+i+"个学生成绩");
            double score = scanner.nextDouble();
            if (score < 0) {
                System.out.println("录入错误");
                break;
            } else {
                count++;
                sum += score;
            }
        }
        System.out.println(sum);
        System.out.println(count);
        System.out.println(sum / count);

    }
}
